<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>字符串排列组合</title>
</head>

<body>
    <script>
        let str = ['a', 'b', 'c'];
        var count = 0;
        function arrange(s) {
            for (var i = 0, length = str.length; i < length; i++) {
                if (s.length == length - 1) {
                    if (s.indexOf(str[i]) < 0) {
                        count++;
                        console.log("组合" + count + "=" + s + str[i]);
                    }
                    continue;
                }
                if (s.indexOf(str[i]) < 0) {
                    arrange(s + str[i]);
                }
            }
        }
        arrange('');

    </script>
</body>

</html>